﻿@{
        
    SelectList saSelectList = null;
    SelectList wdSelectList = null;
    SelectList rtSelectList = null;    
    IList<ASKM.Rachao.Model.City> cityList = null;
    IList<ASKM.Rachao.Model.RegionGaming> rgList = null;
    
    using(var siteFacade = new ASKM.Rachao.Model.Facade.Site())
    {
        var saList = siteFacade.GetSportActivity();
        saSelectList = new SelectList(saList, "SportActivityId", "Name");
        
        var wdList = siteFacade.GetWeekDays();
        wdSelectList = new SelectList(wdList);

        var rtList = siteFacade.GetRangeTime();
        rtSelectList = new SelectList(rtList, "RangeTimeId", "Label");

        rgList = siteFacade.GetRegionGaming();
        cityList = rgList.Select(x => x.City).Distinct().OrderBy(x=> x.Name).ToList();                        
    }

}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/CSSReset.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
</head>
<body>
    <div class="page">
        <div id="header">
            <div id="logo" title="@ASKM.Rachao.Resources.Site.Shared.Global.RachaoSlogan">                
            </div>                     
        </div>
        <div id="nav">
            <ul id="menu">
                <li>@Html.ActionLink("Página Inicial", "Index", "Home")</li>
                <li>@Html.ActionLink("O que é o Rachão?", "About", "Home")</li>
                <li>@Html.ActionLink("Inscreva-se agora mesmo", "About", "Home")</li>
                <li>@Html.ActionLink("Entrar", "About", "Home")</li>
                <li>@Html.ActionLink("Quem Somos", "About", "Home")</li>
                <li>@Html.ActionLink("Versão para Empresas", "About", "Home")</li>
                <li>@Html.ActionLink("Rachão no Celular", "About", "Home")</li>
            </ul>
        </div>
        <div id="searchbar">
            <form action="" id="form_search" name="form_cadastrese" method="post">
            @Html.DropDownList("sportactivity", saSelectList, "Esporte")
            @Html.DropDownList("weekday", wdSelectList, "Dia da Semana")
            @Html.DropDownList("rangetime",rtSelectList,"Horário")
            <select name="regiongaming" id="regiongaming">
                <option value="">Local de Preferência</option>
                @foreach(var city in cityList)
                {                    
                    <optgroup label="@city.Name">@city.Name</optgroup>
                    
                    var regions = rgList.Where(x => x.CityId == city.CityId).OrderBy(x=> x.Name).ToList();
                    foreach (var regionGaming in regions)
                    {
                         <option value="@regionGaming.RegionGamingId">@regionGaming.Name</option>
                    }
                    
                }                
            </select>            
            <input type="submit" class="verde" id="search_playerprofile" title="Encontrar Parceiros" value="Encontrar Parceiros" />
            <input type="submit" class="verde" id="search_rachao" title="Encontrar Rachão" value="Encontrar Rachão" />            
            </form>
        </div>
        <div id="main">
            @RenderBody()
        </div>        
        <div id="footer_text">
            @ASKM.Rachao.Resources.Site.Shared.Global.RachaoFooter
        </div>        
        <div id="footer">                
        </div>
    </div>
</body>
</html>
